//package com.tcs.test.http.jsoup;
//
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.google.common.collect.Lists;
//import org.apache.commons.collections.CollectionUtils;
//import org.apache.commons.lang3.StringUtils;
//import org.jsoup.Jsoup;
//import org.jsoup.nodes.Document;
//import org.junit.Test;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import java.io.BufferedReader;
//import java.io.FileNotFoundException;
//import java.io.FileReader;
//import java.io.IOException;
//import java.util.List;
//
//public class Jsoup1 {
//
//    private final Logger logger = LoggerFactory.getLogger(Jsoup1.class);
//
//    private final String filePath = "G:\\eclipse-workspace\\teacher-course-system\\teacher-course-system-app-parent\\teacher-course-system-test\\src\\test\\resources\\config\\demo.txt";
//
//    @Test
//    public void test() {
//        try {
//            BufferedReader reader = new BufferedReader(new FileReader(filePath));
//            List<SelectBean> selectBeanList = Lists.newArrayList();
//            List<SelectContentBean> selectContentBeanList = Lists.newArrayList();
//            SelectBean selectBean = null;
//            // 算法
//            int index = 0, max = 6, id = 0 , tempIndex = 0;
//            try {
//                String readerLine = null;
//                while ((readerLine = reader.readLine()) != null) {
//                    if (StringUtils.isNotBlank(readerLine) && !readerLine.contains("解析")) {
//                        readerLine = readerLine.replace("。", "").trim();
//                        logger.info("{}", readerLine);
//                        if (++index == 1) {
//                            selectBean = new SelectBean();
//                            selectBean.setTitle(readerLine);
//                            selectBean.setId(++tempIndex);
//                            selectBean.setIndex(tempIndex);
//                        }
//                        if (index > 1 && index <= max - 1) {
//                            SelectContentBean selectContentBean = new SelectContentBean();
//                            selectContentBean.setId(++id);
//                            selectContentBean.setZiMu(this.getZiMu(id));
//                            selectContentBean.setContent(readerLine);
//                            selectContentBeanList.add(selectContentBean);
//                        }
//                        if (index == max) {
//                            selectBean.setDaAn(readerLine);
//                            List<SelectContentBean> tempSelectContentBeanList = Lists.newArrayList();
//                            if (CollectionUtils.isNotEmpty(selectContentBeanList)) {
//                                tempSelectContentBeanList.addAll(selectContentBeanList);
//                            }
//                            selectBean.setSelectContentList(tempSelectContentBeanList);
//                            selectBeanList.add(selectBean);
//                            selectContentBeanList.clear();
//                            index = 0;
//                            id = 0;
//                        }
//                    }
//                }
//                ObjectMapper mapper = new ObjectMapper();
//                String vlaue = mapper.writeValueAsString(selectBeanList);
//                logger.info("list : {} \n , json : {} ", selectBeanList , vlaue);
//            } catch (IOException e) {
//                logger.error("", e);
//            }
//        } catch (FileNotFoundException e) {
//            logger.error("", e);
//        }
//    }
//
//    private String getZiMu(int index) {
//        String result = "";
//        if (index == 1) {
//            result = "A";
//        } else if (index == 2) {
//            result = "B";
//        } else if (index == 3) {
//            result = "C";
//        } else {
//            result = "D";
//        }
//        return result;
//    }
//
//    @Test
//    public void httpRequest() {
//        try {
//            Document doc = Jsoup.connect("https://m.educity.cn/ntce/1873008.html").get();
//            logger.info("doc: {} " , doc.html());
//        } catch (IOException e) {
//            logger.error("", e);
//        }
//    }
//}
